package com.magicodex.bookkeeping.biz.accounting.event;

import android.app.Activity;
import android.view.View;
import android.widget.AdapterView;

import com.magicodex.bookkeeping.R;
import com.magicodex.bookkeeping.ui.accounting.AccountingListViewAdapter;

/**
 * @author mh.z
 */
public class AccountingItemClickListener implements AdapterView.OnItemClickListener {
    private Activity activity;
    private AccountingListViewAdapter adapter;

    public AccountingItemClickListener(Activity activity, AccountingListViewAdapter adapter) {
        this.activity = activity;
        this.adapter = adapter;
    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
        View editFab = activity.findViewById(R.id.fab_edit);
        View deleteFab = activity.findViewById(R.id.fab_delete);

        // 设置编辑和删除按钮可见
        editFab.setVisibility(View.VISIBLE);
        deleteFab.setVisibility(View.VISIBLE);

        // 记录最后点击的位置
        adapter.setLastClickPosition(position);
    }

}
